// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init({ env: 'xiaobai-0gb7xnz4936f2b23' })

// 云函数入口函数
exports.main = async (event, context) => {
  let openid = ''
  if(event.openid){
    openid = event.openid
  }else{
    openid = cloud.getWXContext().OPENID
  }
  const db = cloud.database()

  db.collection('users').where({
    openid
  }).remove()
  db.collection('driver_goods_1').where({
    openid
  }).remove()
  db.collection('driver_goods_2').where({
    openid
  }).remove()
  db.collection('driver_goods_3').where({
    openid
  }).remove()
}